﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace WeiSiCopy
{
    public static class BaseSetting
    {
        public const string SrcPath = "C:\\Source\\Joomla\\WeiSiCopy\\Source\\";
        public const string TempPath = "C:\\Source\\Joomla\\WeiSiCopy\\temp\\";
        public const string DesPath = "C:\\Source\\Joomla\\WeiSiCopy\\Destination\\";
        public const string SitePath = "V:\\www\\";
        public const string MySQLPath = "V:\\MySQL\\data\\";

        public const int MaxThreadCount = 2;

        public const string DBConn = "Provider=SQLOLEDB.1;Password=123456;Persist Security Info=True;User ID=sa;Initial Catalog=SI_CARE;Data Source=VPC-SVR-water;Connect Timeout=2";


        public static void Wei_MoveToAddDate(this FileInfo file, string path, FileSystemInfo f_info)
        {
            if (f_info.Extension.ToUpper() == ".TXT")
            {
                file.MoveTo(path + f_info.Wei_ChangeName());
            }
        }
        public static void Wei_MoveTo(this FileInfo file, string path, FileSystemInfo f_info)
        {
            if (f_info.Extension.ToUpper() == ".TXT")
            {
                file.MoveTo(path + f_info.Name);
            }
        }

        public static string Wei_ChangeName(this FileSystemInfo f_info)
        {
            string datename = DateTime.Now.ToString("yyyy_MM_dd_HH_mm");

            return f_info.Name.Substring(0, f_info.Name.Length - 4) + "_" + datename + ".txt";
        }


        public static List<Apply> Wei_AddRange(this List<Apply> mylist, List<Apply> list)
        {
            if (list != null)
            {
                if (mylist == null)
                {
                    mylist = new List<Apply>();
                }
                mylist.AddRange(list);
            }

            return list;
        }

        public static List<string> GetParser(this string str)
        {
            List<string> list = null;

            char[] delimiterChars = { '$', '=', ';' };
            string[] vlaue = str.Split(delimiterChars);
            if (vlaue.Length > 0)
            {
                if (list == null)
                {
                    list = new List<string>();
                }
                for (int i = 0; i < vlaue.Length; i++)
                {
                    list.Add(vlaue[i].Trim());
                }
            }
            return list;

        }
    }
}
